<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
</head>
<body>
  
 <div id="app">
    <h2>加加减减</h2>
    <ul>
        <li v-for="(item,index) in list" :key="item">
            <span>{{ item }}</span>
            <button @click="del">删除</button>
        </li>
    </ul>
    <button @click="add">生成</button>
 </div>
 <script>
    const app = new Vue({
        el: '#app',
        data: {
            list: [1,7,45,9,5]
        },
        methods:{
            //添加
            add(){
              this.list.push(Math.floor(Math.random() * 100))
            },
            //删除
            del(index){
                this.list.splice(index,1)
            }
        }
    })
 </script>
</body>
</html>